package com.reggie.mapper;

import com.reggie.dto.DishDto;
import com.reggie.pojo.Dish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    List<Dish> findAll(int page, int pageSize, String name);

    @Update("UPDATE dish SET is_deleted=1, update_time=now(), update_user=#{userId} WHERE id=#{id}")
    int delete(Long id, Long userId);

    boolean add(Dish dish);

    Integer edit(Dish dish);

    @Select("SELECT * FROM dish WHERE id=#{id}")
    DishDto find(Long id);

    @Update("UPDATE dish SET status=#{status}, update_time=now(), update_user=#{userId} WHERE id=#{id}")
    Integer editStatus(Long id, Integer status, Long userId);

    List<DishDto> findfindByCategoryOrName(Long categoryId, String name, Integer status);
}
